<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录 - 企业培训平台</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OerSvFjrSpejD8k/l+0oV5WwChJ0Q+idATy+u/KzDq/W" crossorigin="anonymous">
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #165DFF;
            --secondary-color: #4080FF;
            --accent-color: #E8F3FF;
            --text-color: #333647;
            --light-text: #6B7280;
            --border-color: #E5E7EB;
        }

        body.login-page-container {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: linear-gradient(135deg, var(--accent-color) 0%, #ffffff 100%);
            padding: 20px;
        }

        .login-form-card {
            width: 100%;
            max-width: 480px; /* 增大卡片宽度 */
            border-radius: 20px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            background-color: #fff;
            overflow: hidden;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        .login-form-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
        }

        .login-header {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            padding: 35px; /* 增大头部内边距 */
            text-align: center;
            color: white;
            position: relative;
        }

        .login-header h2 {
            font-size: 26px; /* 增大标题字体 */
            font-weight: 600;
            margin-bottom: 8px;
        }

        .login-header p {
            font-size: 15px; /* 增大副标题字体 */
            opacity: 0.8;
        }

        .login-body {
            padding: 45px 40px; /* 增大内容区域内边距 */
        }

        .form-group {
            margin-bottom: 25px; /* 增大表单组间距 */
            position: relative;
        }

        .form-group .form-label {
            display: block;
            font-size: 15px; /* 增大标签字体 */
            font-weight: 500;
            color: var(--text-color);
            margin-bottom: 10px;
        }

        .form-group .form-control {
            height: 54px; /* 增大输入框高度 */
            border-radius: 12px;
            border: 1px solid var(--border-color);
            padding: 0 20px; /* 增大输入框内边距 */
            font-size: 15px; /* 增大输入文字字体 */
            color: var(--text-color);
            transition: border-color 0.3s ease, box-shadow 0.3s ease;
            width: 300px; /* 确保输入框填满宽度 */
        }

        .form-group .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.15);
            outline: none;
        }

        .form-group .form-control::placeholder {
            color: #9CA3AF;
        }

        .form-group i {
            position: absolute;
            right: 20px; /* 调整图标位置 */
            top: 42px; /* 调整图标位置 */
            color: #9CA3AF;
            font-size: 16px; /* 增大图标尺寸 */
        }

        .btn-login {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            color: white;
            border: none;
            border-radius: 12px;
            padding: 16px 0; /* 增大按钮内边距 */
            font-size: 17px; /* 增大按钮文字 */
            font-weight: 500;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            display: block; /* 确保按钮作为块级元素 */
            width: 80%; /* 按钮宽度为父容器的80% */
            margin: 0 auto; /* 水平居中 */
        }

        .btn-login:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(22, 93, 255, 0.25);
        }

        .btn-login:active {
            transform: translateY(0);
            box-shadow: 0 4px 10px rgba(22, 93, 255, 0.25);
        }

        .btn-login::after {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: all 0.6s ease;
        }

        .btn-login:hover::after {
            left: 100%;
        }

        .back-link {
            display: block;
            text-align: center;
            margin-top: 30px; /* 增大底部链接间距 */
            color: var(--light-text);
            font-size: 15px; /* 增大链接文字 */
            transition: color 0.3s ease;
        }

        .back-link:hover {
            color: var(--primary-color);
            text-decoration: none;
        }

        .alert {
            border-radius: 12px;
            padding: 14px 18px; /* 增大提示框内边距 */
            font-size: 15px; /* 增大提示文字 */
            margin-bottom: 25px; /* 增大提示框间距 */
            position: relative;
            border: none;
        }

        .alert-danger {
            background-color: #FFEBEB;
            color: #D8000C;
        }

        .alert-info {
            background-color: #E8F3FF;
            color: #004085;
        }

        .alert i {
            margin-right: 10px; /* 增大图标间距 */
        }
    </style>
</head>
<body class="login-page-container">
<div class="login-form-card">
    <div class="login-header">
        <h2>企业培训平台</h2>
        <p>欢迎使用，请登录您的账户</p>
    </div>

    <div class="login-body">
        <div th:if="${#flash?.containsKey('error')}" class="alert alert-danger" role="alert">
            <i class="fa fa-exclamation-circle"></i>
            <p th:text="${#flash.get('error')}"></p>
        </div>
        <div th:if="${param.error}" class="alert alert-danger" role="alert">
            <i class="fa fa-exclamation-circle"></i>
            用户名或密码无效。
        </div>

        <div th:if="${#flash?.containsKey('logout_success')}" class="alert alert-info" role="alert">
            <i class="fa fa-check-circle"></i>
            <p th:text="${#flash.get('logout_success')}"></p>
        </div>
        <div th:if="${param.logout}" class="alert alert-info" role="alert">
            <i class="fa fa-check-circle"></i>
            您已成功退出。
        </div>

        <form th:action="@{/login}" method="post">
            <div class="form-group">

                <label for="username" class="form-label">用户名</label>
                <div class="position-relative">
                    <i class="fa fa-user"></i>
                    <input type="text" class="form-control" id="username" name="username" required autofocus>
                </div>
            </div>

            <div class="form-group">

                <label for="password" class="form-label">密码</label>
                <div class="position-relative">
                    <i class="fa fa-lock"></i>
                    <input type="password" class="form-control" id="password" name="password" required>
                </div>
            </div>

            <div class="d-grid gap-2">
                <button type="submit" class="btn btn-login">
                    <i class="fa fa-sign-in mr-2"></i> 登 录
                </button>
            </div>
        </form>

        <a th:href="@{/}" class="back-link">
            <i class="fa fa-arrow-left mr-1"></i> 返回首页
        </a>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>